package com.java1412.order.controller;

import com.java1412.common.entity.Goods;
import com.java1412.order.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author java1412
 * @since 2025-05-14 14:18
 */
@RestController
@RequestMapping(value = "/api/v1/goods_order")
public class OrderController {
    @Autowired
    private GoodsService goodsService;

    @GetMapping(value = "/getGoodsByFeign")
    public Object getGoodsByFeign(@RequestParam(value = "goodsId") Integer goodsId) {
        Object goods = goodsService.findByGoodsId(goodsId);
        return goods;
    }

    @GetMapping(value = "/getClusterName")
    public String getClusterName() {
        for (int i = 0; i < 10; i++) {
            System.out.println(goodsService.findClusterName());
        }
        return "执行结束";
    }
//    @Resource
//    private RestTemplate restTemplate;

//    @RequestMapping(value = "/getGoods")
//    public Object save(@RequestParam(value = "goodsId") Integer goodsId) {
//        Goods goods = restTemplate.getForObject(
//                "http://localhost:6001/api/v1/goods/findByGoodsId?goodsId=" + goodsId,
//                Goods.class
//        );
//        return goods;
//    }
}
